﻿using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom;

namespace NRemedy
{
    public class GenerateField
    {
        public void Create(CodeTypeDeclaration classType, string fieldName, Type fieldType)
        {
            if (classType == null) throw new ArgumentNullException("classType");
            if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("fieldName");
            if (fieldType == null) throw new ArgumentNullException("fieldType");

            CodeMemberField _field = new CodeMemberField();
            _field.Name = fieldName;
            _field.Type = new CodeTypeReference(fieldType);
            _field.Attributes = MemberAttributes.Private | MemberAttributes.Final;

            classType.Members.Add(_field);
        }
    }
}
